package com.dhcc.DRGsHosp.application.impl;

import javax.inject.Named;

import org.dayatang.domain.InstanceFactory;
import org.dayatang.querychannel.QueryChannelService;
import org.springframework.transaction.annotation.Transactional;

import com.dhcc.DRGsHosp.application.DepDisMonitorApplication;
import com.dhcc.DRGsHosp.core.domain.DepGroup;


@Named
@Transactional
public class DepDisMoniotrApplicationImpl implements DepDisMonitorApplication {
	
	
	
	private QueryChannelService queryChannel;

    private QueryChannelService getQueryChannelService(){
       if(queryChannel==null){
          queryChannel = InstanceFactory.getInstance(QueryChannelService.class,"queryChannel");
       }
     return queryChannel;
    }
    
    /**
	 * 
	 * @methodname    :getDepGroup
	 * @description   : 获取科室对应的科室组Code和Desc
	 * @param         :
	 * @author        :WangTeng
	 * @return        :
	 * @date          :2015年5月20日
	 */
	public DepGroup getDepGroup(String depCode){
		
		//查询科室表
		StringBuilder jpql = new StringBuilder("select _depGroup from DepGroup _depGroup");
		jpql.append(" where _depGroup.depGroupCode=(select _dep.parDepGroupCode from Department _dep where _dep.depCode='"+depCode+"')");

	   	DepGroup depGroup = (DepGroup) getQueryChannelService().createJpqlQuery(jpql.toString()).singleResult();
	   	
	   	return depGroup;
	}
}